﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using EnvDTE;
using System.Diagnostics;

namespace SolutionNavigateAddIn
{
    public static class UIHierarchyItemsExtension
    {

        public static List<UIHierarchyItem> GetChildrenList(UIHierarchyItems items)
        {
            List<UIHierarchyItem> list = new List<UIHierarchyItem>();
            try
            {
                IEnumerator enumerator = items.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    UIHierarchyItem item = enumerator.Current as UIHierarchyItem;

                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(
                    string.Format(
                        "Method UIHierarchyItemsExtension.GetChildrenList(UIHierarchyItems) generated exception: {0}",
                        e.Message));
            }

            return list;

        }


    }
}